Close Access
The Close Access command closes a file opened with the Open for Access command. It is one of several commands provided by the Read/Write Commands scripting addition. For more information about these commands, see "Using Read/Write Commands,".SYNTAX
close access referenceToFilePARAMETER
- referenceToFile
- A reference of the form
file
nameString oralias
nameString, or a file reference number returned by a previous call to the Open for Access command (see "Notes").
Class: Reference or integerRESULT
NoneEXAMPLES
This example closes the file named To Donald in the specified location if it was previously opened with the Open for Access command.
tell application "Scriptable Text Editor" close access file "Hard Disk:Letters:To Donald"end tellThe next example closes the file associated with the file reference number if the value of myFileRefNumber is a file reference number previously obtained with the Open for Access command.
tell application "Scriptable Text Editor" close access myFileRefNumber end tellNOTES
To specify the name (nameString) of a file, use a string of the form"Disk:Folder1:
as described in Chapter 5, "Objects and References,"
Folder2:...:Filename"
of the AppleScript Language Guide. If you specify only the name of the file (Filename) instead of its entire pathname, AppleScript attempts to find the file in the current directory.If you specify a reference to a file or an alias, the Close Access command attempts to match the reference with a file previously opened with the Open for Access command. If a match is found, Close Access closes the file. If no match is found, Close Access returns error number -43.
If you specify a file reference number previously obtained with the Open for Access command, Close Access closes the file immediately.
ERRORS
Error
numberError message -35 Disk <name> wasn't found. -38 File <name> wasn't open. -43 File <name> wasn't found. -50 Parameter error.